package cn.yxr.controller;

import cn.yxr.pojo.AppInfo;
import cn.yxr.service.AppinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


import java.util.List;

@Controller
public class AppInfoController {
    @Autowired
    private AppinfoService appinfoService;
    @RequestMapping("/select")
    public String query(Model model){
        List<AppInfo> appInfoList = appinfoService.getAppInfoList();
        for (AppInfo appInfo : appInfoList) {
            model.addAttribute("appInfo",appInfo);
        }
        return "appinfo";
    }
    @RequestMapping("/select1")
    public String add3(Model model){
        List<AppInfo> appInfoList = appinfoService.getAppInfoList();
        AppInfo appInfo = new AppInfo(appInfoList);
        model.addAttribute("app",appInfo);
        return "appinfo";
    }
    @RequestMapping("/add1")
    public String add(Model model){
        AppInfo appInfo=new AppInfo();
        int addinfo = appinfoService.addinfo(appInfo);
        if (addinfo>0){
            System.out.println("添加成功");
        }
        return "appstart";
    }
}

